<?php

declare(strict_types=1);

/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

use App\Controller\client\UserDeviceController;
use App\Controller\common\UploadController;
use Hyperf\HttpServer\Router\Router;

Router::addRoute(['GET', 'POST', 'HEAD'], '/', 'App\Controller\IndexController@index');


/**
 * socket通信
 * socket
 */
Router::addServer('ws', function () {
    Router::get('/', 'App\Controller\webSocket\WebSocketController');
});
/**
 * socket通信/chat聊天
 * socket
 */
Router::addServer('ws', function () {
    Router::get('/chat', 'App\Controller\webSocket\ChartWebSocketController');
});
Router::get('/favicon.ico', function () {
    return '';
});

/**
 * =======微信聊天相关接口=========================================================
 */
require_once 'routers/api/api-router.php';

/**
 * =================================================================================
 */
Router::addGroup('/client', function () {
    Router::addGroup('/device', function () {
        Router::post('/login', [UserDeviceController::class, 'login']);  /*设备登录*/
    });
});
Router::addGroup('/common', function () {
    Router::post('/uploadAvatar', [UploadController::class, 'uploadAvatar']);  /*上传文件*/
    Router::post('/uploadChatFile', [UploadController::class, 'uploadChatFile']);  /*上传文件*/
});
